package com.slipper.sfts.order;

import com.slipper.common.util.ResultUtil;
import com.slipper.sfts.api.order.bo.OrderBO;
import com.slipper.sfts.api.order.service.IOrderSv;
import com.slipper.system.common.Constants;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private IOrderSv orderSv;
    
    @PostMapping(value = "/order")
    public String order(@RequestBody OrderBO bo) {
        bo.setMemberId(Constants.getCurrentUser().getMember().getId());
        return ResultUtil.toJson(orderSv.order(bo));
    }

    @PostMapping(value = "/cancel")
    public String cancel(@RequestBody OrderBO bo) {
        bo.setMemberId(Constants.getCurrentUser().getMember().getId());
        return ResultUtil.toJson(orderSv.cancel(bo));
    }
}
